<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
      <title>腳本 | HiAPI-C# 2025 </title>
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <meta name="title" content="腳本 | HiAPI-C# 2025 ">
      
      
      <link rel="icon" href="../../../../../img/HiAPI.favicon.ico">
      <link rel="stylesheet" href="../../../../../public/docfx.min.css">
      <link rel="stylesheet" href="../../../../../public/main.css">
      <meta name="docfx:navrel" content="../../../../../toc.html">
      <meta name="docfx:tocrel" content="../../toc.html">
      
      <meta name="docfx:rel" content="../../../../../">
      
      
      
      <meta name="loc:inThisArticle" content="In this article">
      <meta name="loc:searchResultsCount" content="{count} results for &quot;{query}&quot;">
      <meta name="loc:searchNoResults" content="No results for &quot;{query}&quot;">
      <meta name="loc:tocFilter" content="Filter by title">
      <meta name="loc:nextArticle" content="Next">
      <meta name="loc:prevArticle" content="Previous">
      <meta name="loc:themeLight" content="Light">
      <meta name="loc:themeDark" content="Dark">
      <meta name="loc:themeAuto" content="Auto">
      <meta name="loc:changeTheme" content="Change theme">
      <meta name="loc:copy" content="Copy">
      <meta name="loc:downloadPdf" content="Download PDF">

      <script type="module" src="./../../../../../public/docfx.min.js"></script>

      <script>
        const theme = localStorage.getItem('theme') || 'auto'
        document.documentElement.setAttribute('data-bs-theme', theme === 'auto' ? (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light') : theme)
      </script>

  </head>

  <body class="tex2jax_ignore" data-layout="" data-yaml-mime="">
    <header class="bg-body border-bottom">
      <nav id="autocollapse" class="navbar navbar-expand-md" role="navigation">
        <div class="container-xxl flex-nowrap">
          <a class="navbar-brand" href="../../../../../index.html">
            <img id="logo" class="svg" src="../../../../../img/HiAPI.logo.png" alt="">
            
          </a>
          <button class="btn btn-lg d-md-none border-0" type="button" data-bs-toggle="collapse" data-bs-target="#navpanel" aria-controls="navpanel" aria-expanded="false" aria-label="Toggle navigation">
            <i class="bi bi-three-dots"></i>
          </button>
          <div class="collapse navbar-collapse" id="navpanel">
            <div id="navbar">
              <form class="search" role="search" id="search">
                <i class="bi bi-search"></i>
                <input class="form-control" id="search-query" type="search" disabled placeholder="Search" autocomplete="off" aria-label="Search">
              </form>
            </div>
          </div>
        </div>
      </nav>
    </header>

    <main class="container-xxl">
      <div class="toc-offcanvas">
        <div class="offcanvas-md offcanvas-start" tabindex="-1" id="tocOffcanvas" aria-labelledby="tocOffcanvasLabel">
          <div class="offcanvas-header">
            <h5 class="offcanvas-title" id="tocOffcanvasLabel">Table of Contents</h5>
            <button type="button" class="btn-close" data-bs-dismiss="offcanvas" data-bs-target="#tocOffcanvas" aria-label="Close"></button>
          </div>
          <div class="offcanvas-body">
            <nav class="toc" id="toc"></nav>
          </div>
        </div>
      </div>

      <div class="content">
        <div class="actionbar">
          <button class="btn btn-lg border-0 d-md-none" type="button" data-bs-toggle="offcanvas" data-bs-target="#tocOffcanvas" aria-controls="tocOffcanvas" aria-expanded="false" aria-label="Show table of contents">
            <i class="bi bi-list"></i>
          </button>

          <nav id="breadcrumb"></nav>
        </div>

        <article data-uid="Doc-Task">
          <h1 id="腳本">腳本</h1>

<p><strong>任務</strong>(Task)頁面會依照順序執行腳本，頁面排版順序為由左至右，再由上至下。</p>
<h2 id="腳本工具列">腳本工具列</h2>
<p>個別腳本的工具列的<strong>順序</strong>(Order)欄位為執行順序，如果沒有勾選<strong>啟用</strong>，則該任務會無視執行順序被略過。</p>
<p>工具欄可新增、刪除腳本。</p>
<p><a id="Script"></a></p>
<h2 id="語法與功能">語法與功能</h2>
<p><strong>腳本</strong> (Script) 中的<strong>標題</strong> (Title) 的功能僅為註記，無其他功能，腳本的內容與標題不一定要匹配。</p>
<p>腳本使用原生C#語言，可直接引用<a class="xref" href="../../../../../api/Hi.MachiningProcs.RuntimeApi.html">RuntimeApi</a><small>(API)</small>的成員屬性及成員函數。</p>
<div class="NOTE">
<h5>Note</h5>
<p><strong>基本 C# 語法</strong></p>
<ul>
<li>指令以分號 <code>;</code> 作為結束符號。</li>
<li>可以使用 <code>//</code> 作為行尾註解。</li>
<li>可以使用<code>double.PositiveInfinity</code>、<code>double.NegativeInfinity</code>表示實數中的無限大及無限小。</li>
</ul>
<p>腳本範例：</p>
<pre><code class="lang-csharp">PlayNcFile(&quot;NC/file1.nc&quot;);
</code></pre>
</div>
<p><a id="FileTemplate"></a></p>
<h3 id="多檔案輸出樣板">多檔案輸出樣板</h3>
<p>在有支援路徑樣板的指令中，路徑字串裡的<code>[NcName]</code>會被替換為NC檔案的名稱。</p>
<div class="TIP">
<h5>Tip</h5>
<p><strong>指令範例</strong></p>
<pre><code class="lang-csharp">PlayNcFile(&quot;NC/file1.nc&quot;);
PlayNcFile(&quot;NC/file2.nc&quot;);
WriteShotFiles(&quot;Output/[NcName].shot.csv&quot;, 1);
// 輸出檔案至:
// Output/file1.nc.shot.csv
// Output/file2.nc.shot.csv
OptimizeToFiles(&quot;Cache/Opt-[NcName]&quot;);
// 輸出檔案至:
// Cache/Opt-file1.nc
// Cache/Opt-file2.nc
</code></pre>
</div>
<h2 id="nc碼中的腳本指令">NC碼中的腳本指令</h2>
<p>在註解內，以<code>;@</code>開頭，會在該行NC執行前執行腳本指令。</p>
<div class="TIP">
<h5>Tip</h5>
<p><strong>FANUC NC檔範例，在換刀時更改仿真解析度</strong></p>
<pre><code>...
G40 G17 G49 G54 G80
G91 G28 Z0.0
T01 M06 (;@MachiningResolution_mm=0.03125;)
S1270 M03
G43 Z10. H01
...
</code></pre>
</div>

</article>

        <div class="contribution d-print-none">
        </div>

        <div class="next-article d-print-none border-top" id="nextArticle"></div>

      </div>

      <div class="affix">
        <nav id="affix"></nav>
      </div>
    </main>

    <div class="container-xxl search-results" id="search-results"></div>

    <footer class="border-top text-secondary">
      <div class="container-xxl">
        <div class="flex-fill">
          <span> Copyright © 2025 <a href='https://superhightech.com.tw'>Tech Coordinate</a>. All rights reserved. <a href='https://superhightech.com.tw'>超級高科技股份有限公司</a> © 2025 版權所有 </span>
        </div>
      </div>
    </footer>
  </body>
</html>
